<template>
	<view>
		<view class="lc-goods-box" v-for="(item,index) in list">
			<image :src="baseurl+item.thumbnail" mode="aspectFill" class="lc-goods-img">
			</image>
			<view class="lc-goods-detail">
				<view class="lc-goods-title">{{item.goods.title}}</view>
				<view class="lc-goods-num">销量 {{item.goods.sales}}</view>
				<view class="lc-goods-moneys" @click="goodsDetail(item.goods.id)">
					<image :src="baseurl+'/imgs2/hh7.png'" mode="widthFix"></image>
					<view class="lc-goods-detail-prices">
						<view class="lc-goods-current-price"><text>￥</text>{{item.price}}</view>
						<view class="lc-goods-original-price">￥{{item.market_price}}</view>
					</view>
				</view>
				<view class="lc-goods-con">
					<view class="lc-goods-add">{{item.goods.pingfen}}分 | {{item.goods.shopname}}</view>
					<view class="lc-goods-km">{{item.goods.distance}}km</view>
				</view>
			</view>
		</view>
		<view class="lc-null"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				app: getApp().globalData,
				baseurl: getApp().globalData.baseurl,
				page: 1,
				list: []
			}
		},
		onShow() {
			this.page = 1
			this.list = []
			this.getList()
		},
		methods: {
			getList() {
				this.app.post('/api/wanlshop/user/selzuji', {
					page: this.page,
					lat: uni.getStorageSync('latitude'),
					lng: uni.getStorageSync('longitude'),
				}).then(res => {
					console.log(res)
					this.list = this.list.concat(res.data)
				})
			},
			goodsDetail(id) {
				uni.navigateTo({
					url: '/pages/lc/goodsDetail/goodsDetail?id=' + id
				})
			},
		},
		onReachBottom() {
			this.page += 1;
			this.getList();
		},
	}
</script>

<style lang="scss">
	.lc-goods-box {
		width: 690rpx;
		margin-top: 30rpx;
		background-color: #FFFFFF;
		border-radius: 16rpx;
		padding: 30rpx 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-left: 30rpx;

		.lc-goods-img {
			width: 220rpx;
			height: 220rpx;
			border-radius: 16rpx;
			overflow: hidden;
			margin-left: 30rpx;
		}

		.lc-goods-detail {
			width: 390rpx;
			margin-right: 30rpx;
			display: flex;
			flex-wrap: wrap;
			align-content: space-between;
			height: 220rpx;

			.lc-goods-title {
				width: 100%;
				font-size: 30rpx;
				color: #3D3D3D;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			.lc-goods-num {
				font-size: 24rpx;
				background-color: #F7F7F7;
				color: #666666;
				border-radius: 50rpx;
				padding: 0 20rpx;
				line-height: 40rpx;
			}

			.lc-goods-moneys {
				width: 100%;
				position: relative;

				image {
					width: 100%;
					height: 58rpx;
				}

				.lc-goods-detail-prices {
					position: absolute;
					width: 100%;
					height: 58rpx;
					left: 0;
					top: 0;
					display: flex;
					align-items: center;

					.lc-goods-current-price {
						font-size: 36rpx;
						color: #FB4E2F;
						font-weight: bold;

						text {
							font-size: 26rpx;
						}
					}

					.lc-goods-original-price {
						font-size: 26rpx;
						color: #999999;
						margin-left: 10rpx;
						text-decoration: line-through;
					}
				}
			}

			.lc-goods-con {
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.lc-goods-add {
					width: 300rpx;
					font-size: 22rpx;
					color: #999999;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}

				.lc-goods-km {
					font-size: 22rpx;
					color: #999999;
				}
			}
		}
	}
</style>